﻿@inherits AdminCompontentBase
<MCard Class="@($"{Class} d-flex flex-column px-2 rounded-xl")">
    <MCardTitle class="px-0 py-2">
        <MListItem>
            <MListItemTitle Class="overflow-visible">
                <ColorTag>@T(Channel.Type.ToString())</ColorTag>
            </MListItemTitle>
            <MListItemIcon Class="mr-n2">
                <MButton Small Icon OnClick="HandleEditClick">
                    <SIcon Color="emphasis2">mdi-pencil</SIcon>
                </MButton>
            </MListItemIcon>
        </MListItem>
    </MCardTitle>
    <MCardText class="flex-grow-1 px-0 d-flex flex-column justify-center align-center px-12 text-center">
        <div class="h5 emphasis--text text-truncate full-width">@Channel.DisplayName</div>
        <div class="body2 regular3--text text-truncate full-width">@Channel.Code</div>
    </MCardText>
    <div style="max-height:64px;">
        @if (!string.IsNullOrEmpty(Channel.Description))
        {
            <div class="fill-hover body px-2 py-1 regular2--text text-justify line-clamp-2 rounded">@Channel.Description</div>
        }
    </div>
    <MCardActions class="px-3 pb-3">
        <MSpacer />
        <span class="caption regular3--text">@Channel.ModificationTime.Humanize(culture:I18n.Culture) </span>
        <span class="d-flex px-1" style="height: 8px">
            <MDivider Vertical />
        </span>
        <span class="caption regular2--text">@Channel.ModifierName</span>
    </MCardActions>
</MCard>

@code {
    [Parameter]
    public EventCallback OnEditClick { get; set; }

    [EditorRequired]
    [Parameter]
    public ChannelDto Channel { get; set; } = null!;

    private async Task HandleEditClick()
    {
        if (OnEditClick.HasDelegate)
        {
            await OnEditClick.InvokeAsync();
        }
    }
}